#include <iostream>
#include <vector>
#include <unistd.h>
#include <string.h>
using namespace std;
class Solution
{
public:
    bool find(vector<char> &vec, char c)
    {
        for (int i = 0; i < vec.size(); i++)
        {
            if (vec[i] == c)
            {
                return true;
            }
        }
        return false;
    }
    /**
     * 
     * @param s string字符串 
     * @return int整型
     * 
     * 思路：找到以每个字符开头的所有的不重复子串长度，取最大的那个
     */
    int lengthOfLongestSubstring(string s)
    {
        // write code here

        if (s.length() <= 1)
        {
            return s.length();
        }
        int num = 1;
        int length = s.length();
        const char *data = s.data();
        vector<char> str;
        for (int i = 0; i < length; i++)
        {
            str.swap(vector<char>());
            str = s[i];
            int j = i + 1;
            while (j < s.length() && (str.find(s[j]) == -1))
            {
                str = str + s[j];
                j++;
            }
            if (str.length() > num)
            {
                num = str.length();
            }
        }

        return num;
    }
};
int main()
{
    std::string str = "wlrbbmqbhcdarzowkkyhiddqscdxrjmowfrxsjybldbefsarcbynecdyggxxpklorellnmpapqfwkhopkmco";
    Solution so;
    cout << so.lengthOfLongestSubstring(str) << endl;

    return 0;
}